package d9_com.itheima.Date_jdk8;

import java.time.Duration;
import java.time.LocalDateTime;

public class Test8_Duration {
    //计算两个时间间隔
    public static void main(String[] args) {
        LocalDateTime start = LocalDateTime.of(2025, 6, 7, 8, 11, 2);
        LocalDateTime end = LocalDateTime.of(2025, 11, 11, 11, 11, 11);
        //1、创建Duration对象。
        Duration dration = Duration.between(start, end);

        //2、获取两个时间对象相差的信息。
        System.out.println(dration.toDays());//间隔多少天
        System.out.println(dration.toHours());//间隔多少小时
        System.out.println(dration.toMinutes());//间隔多少分
        System.out.println(dration.toSeconds());//间隔多少秒
        System.out.println(dration.toMillis());//间隔多少毫秒
        System.out.println(dration.toNanos());//间隔多少纳秒
}
}
